package org.tso.bs.server.handler;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.OutputStream;

import org.tso.bs.server.Head;

public class RegHandler extends Handler {

	public RegHandler(Head head) {
		super(head);
	}

	@Override
	public void run() {
		System.out.println("test");
		byte[] content = new byte[getHead().getLength()];
		try {
			BufferedInputStream bis = new BufferedInputStream(this.getSocket()
					.getInputStream());
			bis.read(content);
			System.out.println(new String(content, getHead().getEncoding()));

			OutputStream os = getSocket().getOutputStream();
			os.write("SUCC:10000".getBytes());
			os.flush();
			getSocket().close();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}
